package lec05.am;

import java.awt.Button;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.JOptionPane;

public class FrameDemo2 extends Frame implements ActionListener, WindowListener {
	public static void main(String[] args) {
		new FrameDemo2();
	}

	Button ok;
	Button cancel;

	public FrameDemo2() {
		this.setLayout(new FlowLayout());
		ok = new Button("OK");
		this.add(ok);
		this.add(cancel = new Button("CANCEL"));
		this.setSize(400, 300);
		this.addWindowListener(this);
		ok.addActionListener(this);
		cancel.addActionListener(this);
		this.setVisible(true);
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		if (e.getSource() == ok)
			JOptionPane.showMessageDialog(null, "OK");
		else if (e.getSource() == cancel)
			JOptionPane.showMessageDialog(null, "CANCEL");

	}

	@Override
	public void windowOpened(WindowEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void windowClosing(WindowEvent e) {
		System.exit(0);

	}

	@Override
	public void windowClosed(WindowEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void windowIconified(WindowEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void windowDeiconified(WindowEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void windowActivated(WindowEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void windowDeactivated(WindowEvent e) {
		// TODO Auto-generated method stub

	}

}
